package com.itcv.resident.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itcv.resident.entity.ResidentBusiness;
import com.itcv.resident.mapper.ResidentBusinessMapper;
import com.itcv.resident.service.IResidentBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2024-06-26
 */
@Service
public class ResidentBusinessServiceImpl extends ServiceImpl<ResidentBusinessMapper, ResidentBusiness> implements IResidentBusinessService {

    @Autowired
    private ResidentBusinessMapper businessMapper;

    @Override
    public IPage<ResidentBusiness> selectPageByWrapper() {
        LambdaQueryWrapper<ResidentBusiness> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(ResidentBusiness :: getSex,1);
        Page<ResidentBusiness> businessPage = new Page<>(1,10,false);//是否查询总数
        IPage<ResidentBusiness> businessIPage = businessMapper.selectPage(businessPage,lambdaQueryWrapper);
        return businessIPage;
    }

    /**
     * 自定义sql分页查询
     * @return
     */
    @Override
    public IPage<ResidentBusiness> selectPageByAuto(String name) {
        IPage<ResidentBusiness> residentBusinessIPage = businessMapper.selectByParam(new Page<>(1,2),"李明");
        return residentBusinessIPage;
    }
}
